<?php

class Departament_Model_DbTable_Departament extends Zend_Db_Table_Abstract {

    protected $_name = 'departament';

    public function getCombo() {
        if (isset($_GET['table']) and $_GET['table'] == 'CLIENT')
            $this->_name = 'client';
        else if (isset($_POST['type'])) {
            $this->_name = strtolower($_POST['type']);
            $select = $this->_db->select()
                    ->from($this->_name, array('key' => 'id', 'value' => 'name'));
            $result = $this->getAdapter()->fetchAll($select);
            return $result;
        }
        if (!isset($_GET['table']) and !isset($_POST['type']))
            return null;
        $select = $this->_db->select()
                ->from($this->_name, array('key' => 'id', 'value' => 'name'));
        $result = $this->getAdapter()->fetchAll($select);
        return json_encode($result);
    }

    public function getComboDep() {
        $this->_name = 'departament';
        $select = $this->_db->select()
                ->from($this->_name, array('key' => 'id', 'value' => 'name'));
        $result = $this->getAdapter()->fetchAll($select);
        return $result;
    }

}